$(function(){
    obj.init();
});
var obj = new JsFun();
var ctrlUrl = 'admire/admireCommentCtrl';
function JsFun() {
    'use strict';
    return {
        dataGrid: null,
        params: {},
        dom: {},
        init: function () {
            this.dataGrid = new xhDataGrid($('#List'), 'admire/getAdmireCommentList');
            this.dataGrid.parseToolbar().init().activeButton(['recover','deny','del']);
            this.funObj().bindDataGridEvent();
            this.listener();
        },
        listener: function () {
            var that = this;
            //恢复
            $('#recover').click(function () {
                if (xhExtra.buttonDisabled($(this))) return false;
                that.funObj().recover();
            });
            //屏蔽
            $('#deny').click(function () {
                if (xhExtra.buttonDisabled($(this))) return false;
                that.funObj().deny();
            });
            //删除
            $('#del').click(function () {
                if (xhExtra.buttonDisabled($(this))) return false;
                that.funObj().del();
            });
            //搜索
            $('#bt_list_search').click(function () {
                that.funObj().search();
            })
        },
        funObj: function () {
            var that = this;
            return {
                bindDataGridEvent: function () {
                    xhExtra.clearLoadSuccess(that.dataGrid);
                    that.dataGrid.onDblClickRow = function (index,data) {
                        var content = '<div class="row" style="width:95%;padding-left:20px;margin-bottom:5px;"><div class="col-md-12" style="margin-top:15px;"><span>用户:&nbsp;&nbsp;</span>'+data.userName+'&nbsp;&nbsp;&nbsp;&nbsp;<span>时间:&nbsp;&nbsp;</span>'+data.createTime+'</div></div>'+
                            '<div class="row" style="padding:20px;font-size:14px;height:530px;width:100%;word-break:break-all;"><div class="col-md-12">'
                            +data.content+
                            '</div></div>';
                        window.top.xhTop.showModal(
                            {
                                id: 'xh_modal',
                                title: data.title,
                                content: content,
                                size: 'md',
                                button: false,
                                backClose: true,
                                background: true,
                                onOpen: null,
                                onConfirm: null
                            }
                        )
                    };
                },
                recover: function () {
                    xhExtra.askChangeStatus(ctrlUrl, {
                        commentids: that.dataGrid.getSelectValues("id"),
                        type: 'recover'
                    }, that.dataGrid, '是否恢复?');
                },
                deny: function () {
                    xhExtra.askChangeStatus(ctrlUrl, {
                        commentids: that.dataGrid.getSelectValues("id"),
                        type: 'deny'
                    }, that.dataGrid, '是否屏蔽?');
                },
                del: function () {
                    xhExtra.askChangeStatus(ctrlUrl, {
                        commentids: that.dataGrid.getSelectValues("id"),
                        type: 'del'
                    }, that.dataGrid, '是否删除?');
                },
                search: function () {
                    var comment_keyword = $("input[id='search']").val();
                    that.dataGrid.reload({
                        comment_keyword: comment_keyword
                    });
                }
            }
        }
    }
}




